package api

import (
	"api_client/basic/config"
	__ "api_client/basic/proto"
	"api_client/pkg"
	"github.com/gin-gonic/gin"
	"log"
	"net/http"
)

func VideoUpload(c *gin.Context) {
	// 单文件
	file, _ := c.FormFile("file")
	log.Println(file.Filename)

	dst := "D:\\gowork\\src\\zg4\\2212a\\ks\\you_ku\\file_name\\" + file.Filename
	// 上传文件至指定的完整文件路径
	c.SaveUploadedFile(file, dst+file.Filename)
	url := pkg.UploadOss(file.Filename)
	r, err := config.ApiClientClient.Upload(c, &__.UploadReq{})
	if err != nil {
		log.Fatalf("could not greet: %v", err)
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code": r.Code,
		"msg":  r.Msg,
		"data": url,
	})
}
